package com.drugmanage.Base;


import com.drugmanage.constant.DmConstant;
import com.drugmanage.model.ResultInfo;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;

public class BaseController {
	
	private ResultInfo resultInfo = new ResultInfo();
	@ModelAttribute
	public void preMethod(HttpServletRequest request){
		request.setAttribute("ctx", request.getContextPath());
	}
	
	public ResultInfo success(String msg){
		resultInfo.setMsg(msg);
		resultInfo.setCode(DmConstant.OP_SUCCESS_CODE);
		return resultInfo;
	}
	
	public ResultInfo success(String msg, Object obj){
		resultInfo.setMsg(msg);
		resultInfo.setCode(DmConstant.OP_SUCCESS_CODE);
		resultInfo.setResult(obj);
		return resultInfo;
	}
}
